<?php
defined('_JEXEC') or die;
$column = $this->params->get('subcat_column', 2);
$text = $this->params->get('subcat_desc_text');
?>
<?php if (count($this->children[$this->category->id]) > 0 && $this->maxLevel != 0) : ?>
	<?php foreach($this->children[$this->category->id] as $id => $child) : ?>
		<?php
		if ($this->params->get('show_empty_categories') || $child->numitems || count($child->getChildren())) :			
		?>
		<div class="subCat<?php if(($id+1)%$column == 0):?> lastcol<?php endif;?>">        	
            <?php if($this->escape($child->getParams()->get('image'))&& $this->params->get('show_subcat_image')) :?>
			<div class="subCatImage">
            	<a href="<?php echo JRoute::_(ContentHelperRoute::getCategoryRoute($child->id));?>">
            	<img src="<?php echo $this->escape($child->getParams()->get('image')); ?>" alt="<?php echo $this->escape($child->title); ?>" />
           		</a>            
            </div>  
            <?php endif;?>          
            <h3 class="subCatTitle">
				<a href="<?php echo JRoute::_(ContentHelperRoute::getCategoryRoute($child->id));?>">
				<?php echo $this->escape($child->title); ?></a>				
            </h3>
			<?php if ($this->params->get('show_subcat_desc') == 1 && $child->description) :?>
			<div class="subCatDesc">
					<?php echo mb_substr(strip_tags(JHtml::_('content.prepare', $child->description)),0, $text, 'UTF-8'); if (strlen(strip_tags(JHtml::_('content.prepare', $child->description)))>$text) echo '...'; ?>
			</div>	
            <?php endif; ?>
			<?php if ( $this->params->get('show_cat_num_articles',1)) : ?>
           	<div class="subCatCounter">
			<?php echo JText::_('COM_CONTENT_NUM_ITEMS') ; ?>
			<?php echo $child->getNumItems(true); ?>
			</div>
			<?php endif ; ?>
			<?php if (count($child->getChildren()) > 0):
				$this->children[$child->id] = $child->getChildren();
				$this->category = $child;
				$this->maxLevel--;
				if ($this->maxLevel != 0) :
					echo $this->loadTemplate('sublink');
				endif;
				$this->category = $child->getParent();
				$this->maxLevel++;
			endif; ?>            
		</div>        
        <?php if(($id+1)%$column == 0&&($id+1!=sizeof($this->children[$this->category->id]))):?>
        <div class="subCatRowClr"></div>        
        <?php endif;?>
        
		<?php endif; ?>
	<?php endforeach; ?>
<?php endif; ?>
